<include file="default/Index/header" />

<link rel="stylesheet" href="{$Think.CSS_PATH}lhgdialog.css">
<link rel="stylesheet" href="{$Think.CSS_PATH}shangjibao_side.css">

<script type="text/javascript" src="{$Think.JS_PATH}lhgcore.js"></script>
<script type="text/javascript" src="{$Think.JS_PATH}lhgdialog.js"></script>
<script type="text/javascript" src="{$Think.JS_PATH}shangjibao_side.js"></script>
<!-- <script type="text/javascript" src="{$Think.JS_PATH}jquery.imagescroller.js"></script> -->
<script type="text/javascript" src="{$Think.JS_PATH}jquery.validate.min.js"></script>
    <div class="crumbs">
        <strong>You are here ： </strong><a href="/">Home</a><em>></em><span>{:catpos($catid)}</span>
    </div>
    <div class="w1000">
        <div class="fl w190">
            <include file="default/Index/left" />
        </div>
        <div class="fr w790">
            <div class="productcont">
                <div class="fl">
                    <?php
                        if($Detail['thumb']){
                            array_unshift($Detail['pictureurls'], array('url'=>$Detail['thumb']));
                        }

                        $first_img = $Detail['pictureurls'][0][url];
                    ?>
                    <div class="zoom_mian">
                        <div class="jqzoom" id="spec-n1"><img src="{$first_img}" jqimg="{$first_img}" style="width:250px;height:250px;" />
                        </div>
                    </div>
                    <div class="small_img">
                        <foreach name="Detail.pictureurls" item="v">
                            <img <eq name="k" value="0"> class="active"</eq> src="{$v[url]}" />
                        </foreach>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="fr">
                    <h2>{$Detail.title}</h2>
                    <a href="javascript:;" onclick="add_inquiry();"><img src="{$Think.IMG_PATH}favorites.png" />Add to Inquiry</a>
                    <a href="mailto:Manager@MetalsExporter.com"><img src="{$Think.IMG_PATH}msg.png" />Manager@MetalsExporter.com</a>
                    <!--<a href="#"><img src="{$Think.IMG_PATH}whatsapp_logo.png" />gokinghardware</a>-->
                    <a href="javascript:;" onclick="show_inquiry_list();"><img src="{$Think.IMG_PATH}inquiry.png" />Your Inquiry List</a>
                    <div class="clear"></div>
                </div>
                <div class="clear"></div>
                <div class="main_title">
                    <h3>Product Detailed Specification</h3>
                </div>
                {$Detail.content}
                <div class="morepro">
                    <notempty name="next_page">
                        <p><strong>Next ：</strong><a href="{:getUrl($next_page['catid'], $next_page['id'])}">{$next_page[title]}</a></p>
                    </notempty>
                    <notempty name="previous_page">
                        <p><strong>Prev ：</strong><a href="{:getUrl($previous_page['catid'], $previous_page['id'])}">{$previous_page[title]}</a></p>
                    </notempty>
                    
                    <div class="clear"></div>
                </div>
            </div>
        <notempty name="pos_category">
            <div class="in_newProducts_pp" id="cc4" style="height:150px; width:780px;">
                <div id="btnNext4" style="float:left;margin-top: 50px;width: 30px; cursor: pointer;">
                    <img src="{$Think.IMG_PATH}feature_left.gif">
                </div>
                <div class="conter">
                    <div class="in_newProducts_pplogo" id="listBox4" style="height: 128px; overflow: hidden;">
                        <ul id="list4" style="margin-left: 0px;">
                            <foreach name="pos_category" item="r">
                                <li><a href="{:getUrl($r['catid'], $r['id'])}" title="{$r[title]}" target="_blank"><img src="{$r[thumb]}" width="130" height="128" alt="{$r[title]}" class="in_new_leftlogoimg"></a>
                                <div style="text-align: center;">
                                    <a href="{:getUrl($r['catid'], $r['id'])}" title="{$r[title]}" target="_blank">{$r[title]}</a>
                                </div></li>
                            </foreach>
                        </ul>
                    </div>
                </div>
                <div id="btnPrev4" style="float:left;margin-top: 50px;width: 30px; cursor: pointer;">
                    <img src="{$Think.IMG_PATH}feature_right.gif">
                </div>
                <div class="clear1"></div>
            </div>
        </notempty>
        <form name="feedback" id="feedback">
                <div class="main_title">
                    <h3>Leave your message, we will contact you the first time</h3>
                </div>
                <div>
                    <span><em>*</em>Product's Name</span> <input class="text" type="text" name="title" value="{$Detail.title}" />
                </div>
                <div>
                    <span><em>*</em>Your Name</span> <input class="text" type="text" name="name" placeholder="Please enter your name!"/>
                </div>
                <div>
                    <span><em>*</em>Email</span> <input class="text" type="text" name="email" placeholder="Please Enter Your Email Address"/>
                </div>
                <div>
                    <span>Company's Name</span> <input class="text" type="text" name="companyName" />
                </div>
                <div>
                    <span><em>*</em>Tel</span> <input class="text" type="text" name="tel" />
                </div>
                <div>
                    <span><em>*</em>Message</span>
                    <textarea name="message"></textarea>
                </div>
                <div class="result" style="display: none;">
                        Your inquiry had been submitted successfully , we will try our best to
                        reply as soon as possible , thank you !
                </div>
                <div>
                    <span>&nbsp;</span> 
                    <button class="submit" type="submit" style="margin: 0px 0px 30px 0px">Send Inquiry</button>
                </div>
            </form>
        </div>
        <div class="clear"></div>
    </div>
<script type=text/javascript>
    $(function(){
       $(".jqzoom").jqueryzoom({
            xzoom:400,
            yzoom:400,
            offset:10,
            position:"right",
            preload:1,
            lens:1
        });
        $("#spec-list img").bind("mouseover",function(){
            var src=$(this).attr("src");
            $("#spec-n1 img").eq(0).attr({
                src:src.replace("\/n5\/","\/n1\/"),
                jqimg:src.replace("\/n5\/","\/n0\/")
            });
            $(this).css({
                "border":"2px solid #ff6600",
                "padding":"1px"
            });
        }).bind("mouseout",function(){
            $(this).css({
                "border":"1px solid #ccc",
                "padding":"2px"
            });
        });
        $("#feedback").validate({
            rules: {
                title: "required",
                name: "required",
                tel: {
                    required: true,
                },
                email: {
                    required: true,
                    email: true
                },
                message: {
                    required: true,
                }
            },
            submitHandler: function(form) {
                $(".submit").attr('disabled', true);
                $(".submit").html('Submitting your inquiry');
                $.ajax({
                    type: 'post',
                    url: '{:U('message')}',
                    data: $("#feedback").serialize(),
                    success: function(data) {
                        if(data.flag){
                            $(".result").show();
                        }else{
                            $(".result").show();
                            console.log(data.msg)
                        }
                        $(".submit").html('Send Inquiry');
                    }
                })
            }
        })
    })
    
    function add_inquiry(){
        var productArray = {};
        var productStr;

        productStr = $.cookie('productArray');

        productArray =  $.cookie('productArray') ? str2Array($.cookie('productArray')) : {};
        //记录当前产品值
        productArray[{$Detail.id}] = ["{$Detail.id}", "{:str_replace(PHP_EOL, '', $Detail['title'])}", "{$Detail.thumb}", "{$Detail.url}"];

        productStr = obj2Str(productArray);
        $.cookie('productArray', productStr, {"path":"/"});
        alert('Add to inquiry list successfully!');

    }
    
    function show_inquiry_list(){
        J.dialog.get({ id: 'view_daozhan',title: 'Inquiry',width:'820', height: '500', page: '{:U('show_inquiry')}',cover: true });
    }
    //cookie里的值转化成数组， 形如 1||测试1||测试1图片地址@@2|测试2|测试2图片地址
    function str2Array(str){
        return eval('('+str+')'); 
    }
    function obj2Str(obj) {
        switch (typeof(obj)) {
        case 'object':
            var ret = [];
            if (obj instanceof Array) {
                for (var i = 0, len = obj.length; i < len; i++) {
                    ret.push(obj2Str(obj[i]));
                }
                return '[' + ret.join(',') + ']';
            } else if (obj instanceof RegExp) {
                return obj.toString();
            } else {
                for (var a in obj) {
                    ret.push(a + ':' + obj2Str(obj[a]));
                }
                return '{' + ret.join(',') + '}';
            }
        case 'function':
            return 'function() {}';
        case 'number':
            return obj.toString();
        case 'string':
            return "\"" + obj.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g, function (a) {
                return ("\n" == a) ? "\\n" : ("\r" == a) ? "\\r" : ("\t" == a) ? "\\t" : "";
            }) + "\"";
        case 'boolean':
            return obj.toString();
        default:
            return obj.toString();
        }
    }

</script>
<script src="{$Think.JS_PATH}jqzoom.js" type=text/javascript></script>
<include file="default/Index/footer" />